package cn.wsalix.biz.entity;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import cn.anlaser.entity.CommonEntity;
import cn.wsalix.status.ActEnum;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "BIZ_ADVERTISE")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@EntityListeners({ AuditingEntityListener.class })
@Data
@EqualsAndHashCode(exclude={},callSuper = false)
@ToString(exclude = { })
public class Advertise extends CommonEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 633095097961655162L;
	private String code;//广告编码
	private String logo;
	private String title;//广告宣传页标题
	private String httpUrl;//广告宣传页地址
	@Lob
	@Basic(fetch = FetchType.LAZY)
	@Column(name = "CONTENT", columnDefinition = "TEXT", nullable = true, length = 100000)
	private String content;
	private String remark;
	/**
	 * 单宣传页时，内容保存在content
	 * 作废：多宣传页时，内容分别在每个Article
	 */
	//private boolean singleArt;//是否单宣传页,注：不在使用
	//private boolean singleImage;//是否单图片,注：不在使用，多图直接到RelationImage中根据外键查找
	//private Long artId;//广告宣传页IDa
	
	@JsonIgnore
	@ManyToOne(cascade = CascadeType.MERGE, optional = true, fetch = FetchType.LAZY)
	@JoinColumn(foreignKey = @ForeignKey(name = "FK_AD_CATEGORY"), name = "CAT_ID")
	private Category category;
	private ActEnum status;
	@Transient
	private boolean select = false;
}
